<template>
  <div>
    <!-- 上方搜索栏 -->
    <div class="ty_search">
      <el-form :inline="true" :model="formInline" label-width="90px">
        <el-form-item label="编号" size="mini">
          <el-input
            v-model="formInline.user"
            placeholder="请输入编号"
          ></el-input>
        </el-form-item>

        <el-form-item label="所在场所" size="mini">
          <el-input
            v-model="formInline.user"
            placeholder="请输入场所"
          ></el-input>
        </el-form-item>

        <el-form-item label="责任单位" size="mini">
          <el-input
            v-model="formInline.user"
            placeholder="请输入责任单位"
          ></el-input>
        </el-form-item>

        <el-form-item label="所在区域" size="mini">
          <el-select v-model="formInline.TYPE" placeholder="请选择所在区域">
            <el-option label="长春1" value="7"></el-option>
            <el-option label="长春2" value="8"></el-option>
            <el-option label="长春3" value="9"></el-option>
            <el-option label="长春4" value="10"></el-option>
            <el-option label="长春5" value="11"></el-option>
            <el-option label="长春6" value="12"></el-option>
            <el-option label="长春7" value="13"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="审批状态" size="mini">
          <el-select v-model="formInline.TYPE2" placeholder="请选择审批状态">
            <el-option label="待审批" value="7"></el-option>
            <el-option label="已备案" value="8"></el-option>
            <el-option label="已注销" value="9"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item size="mini">
          <el-button type="primary" @click="onSubmit(formInline)"
            >查询</el-button
          >
          <el-button @click="cancel">清空</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-card>
      <!-- 表格上方按钮 -->
      <div style="margin-bottom: 10px">
        <el-button type="primary" size="mini" @click="add"
          >新增备案申请</el-button
        >
      </div>
      <el-table
        border
        ref="multipleTable"
        :data="tableData"
        style="width: 100%"
        height="40vh"
      >
        <el-table-column prop="NAME" label="电子屏编号"></el-table-column>
        <el-table-column prop="NAME" label="所在场所"></el-table-column>
        <el-table-column prop="NAME" label="所在区域"></el-table-column>
        <el-table-column prop="NAME" label="所属街道"></el-table-column>
        <el-table-column prop="NAME" label="责任单位"></el-table-column>
        <el-table-column prop="NAME" label="审批状态"></el-table-column>
        <el-table-column fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <el-button type="text" size="small">查看</el-button>
            <el-button type="text" size="small" @click="approve">审批</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <MyPagination
        :pagination="pagination"
        @current-change="pageChange"
        @size-change="sizeChange"
      ></MyPagination>

      <Form ref="form" />
      <Approve ref="approve" @submit="approveSubmit"/>
    </el-card>
  </div>
</template>
<script>
import MyPagination from "@/components/common/pagination.vue";
import Form from "./form.vue";
import Approve from "../components/approve.vue"
export default {
  components: {
    MyPagination,
    Form,Approve
  },
  data() {
    return {
      tableData: [
        {
          NAME: "测试数据",
        },
      ],
      pagination: {
        limit: 20,
        page: 1,
        total: 100,
      },
      formInline: {
        user: "",
        TYPE: "",
        TYPE2: "",
      },
    };
  },
  created() {
    // this.onSubmit(this.formInline);
  },
  methods: {
    add() {
      this.$refs.form.isShow();
    },
    approve(){
      this.$refs.approve.isShow();
    },
    approveSubmit(data){
      console.log(data,"data--")
      this.$refs.approve.close();
    },
    onSubmit(formInline) {
      plstutatuscfApproveInfo({
        page: this.pagination.page,
        limit: this.pagination.limit,
        TYPE: this.formInline.TYPE,
        search: this.formInline.user,
      }).then((res) => {
        this.tableData = res.body;
      });
    },
    cancel() {
      // this.searchData.BUILDING_ID = "";
      // this.searchData.FLOOR_ID = "";
      // this.searchData.NAME = "";
      // this.get_list();
    },
    pageChange(val) {
      this.pagination.page = val;
      this.onSubmit(this.formInline);
    },
    sizeChange(val) {
      this.pagination.limit = val;
      this.onSubmit(this.formInline);
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-card__body {
  height: 100%;

  width: 100%;
}
</style>
